<template>
  <div class="c--locale-lang">
    <el-dropdown @command="handleCommand">
      <span class="el-dropdown-link">
        <span>{{$t('locale.title')}}</span>
        <i class="el-icon-arrow-down el-icon--right"></i>
      </span>
      <el-dropdown-menu slot="dropdown">
        <el-dropdown-item command="zh-CN">中文简体(zh-CN)</el-dropdown-item>
        <el-dropdown-item command="en">English</el-dropdown-item>
      </el-dropdown-menu>
    </el-dropdown>
  </div>
</template>

<script>
import Cookies from 'js-cookie'
export default {
  methods: {
    handleCommand (language) {
      // this.$message('click on item ' + language)
      Cookies.set('language', language)
      this.$i18n.locale = language
    }
  }
}
</script>

<style lang="scss">
.c--locale-lang {
  .el-dropdown-link {
    cursor: pointer;
    color: #409eff;
  }
  .el-icon-arrow-down {
    font-size: 12px;
  }
}
</style>
